package cn.alcatraz.controller;

import cn.alcatraz.domain.AjaxResult;
import cn.alcatraz.domain.Store;
import cn.alcatraz.feign.feignClients;
import cn.alcatraz.mapper.ProductMapper;
import cn.alcatraz.dto.Productdto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private feignClients feignClientss;

    @PostMapping
    public AjaxResult save(@RequestBody Productdto productdto){
        productMapper.save(productdto);
        Store store = new Store();
        store.setProductId(productdto.getId());
        store.setNumber(productdto.getNumber());
        return feignClientss.save(store);
    }

}
